package com.itcast.chengma.web.controller;

import com.itcast.chengma.domain.vo.CommentVo;
import com.itcast.chengma.domain.vo.QuestionVo;
import com.itcast.chengma.service.CommentService;
import com.itcast.chengma.service.QuestionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 问题web层控制器
 *
 * @Author XiaoJiangShi
 * @Date 2022/8/25 8:52
 * @Blog blog.XiaoJiangShi.net/996.mba
 * @Description: 问题web层控制器
 */
@Slf4j
@RestController
@RequestMapping("/question")
public class QuestionController {

    @Autowired
    private QuestionService questionService;

    @Autowired
    private CommentService commentService;

    /**
     * 获取所有问题集合
     * @return 问题集合
     */
    @GetMapping("/list")
    public List<QuestionVo> list(){
        return questionService.listByAll();
    }

    /**
     * 获取所有评论集合
     * @param id 问题id
     * @return 评论集合
     */
    @GetMapping("/comment")
    public List<CommentVo> comment(Long id){
        return commentService.getListById(id);
    }
}

